const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const {CleanWebpackPlugin} = require('clean-webpack-plugin');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')

module.exports = {
    mode: 'development',
    devtool: 'inline-source-map',
    entry: {
        fpsTraining: './src/fps-training/index.js',
        project1: './src/project1/index.js'
    },
    output: {
        filename: '[name].bundle.[hash].js',
        path: path.resolve(__dirname, 'dist'),
        publicPath: '/'
    },
    plugins: [
        new CleanWebpackPlugin(),
        new HtmlWebpackPlugin({
            filename: "fpsTraining.html",
            chunks: ['fpsTraining'],
            template: "./templates/fpsTraining.html",
            minify: {
                removeComments: true,
                collapseWhitespace: true
            }
        }),
        new HtmlWebpackPlugin({
            filename: "project1.html",
            chunks: ['project1'],
            template: "./templates/project1.html",
            minify: {
                removeComments: true,
                collapseWhitespace: true
            }
        }),
        // new UglifyJsPlugin()
    ],
    module: {
        rules: [
            {test: /\.css$/, use: ['style-loader', 'css-loader']},
            {test: /\.ts$/, use: 'ts-loader'}
        ]
    }
};
